__author__ = 'zhouqi'

class Math(object):
    @classmethod
    def Combination (cls, n, m):
        if (n > 0 and m <= 0) or (n > m) or n < 0 or (n != 0 and m <= 0):
            return 0
        result = 1
        for i in range(1, m - n + 1):
            result = result * (m - i + 1) / i
        return result

    @classmethod
    def Permutation(cls, n):
        if n <= 0:
            return 0
        result = 1
        for i in range(1, n + 1):
            result = result * i
        return result